package cn.iocoder.yudao.module.erp.dal.mysql.contractpaymentplan;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.contractpaymentplan.vo.ContractPaymentPlanPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.contractpaymentplan.ContractPaymentPlanDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 合同付款计划 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ContractPaymentPlanMapper extends BaseMapperX<ContractPaymentPlanDO> {

    default PageResult<ContractPaymentPlanDO> selectPage(ContractPaymentPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ContractPaymentPlanDO>()
                .eqIfPresent(ContractPaymentPlanDO::getContractNo, reqVO.getContractNo())
                .likeIfPresent(ContractPaymentPlanDO::getContractName, reqVO.getContractName())
                .eqIfPresent(ContractPaymentPlanDO::getPaymentRemark, reqVO.getPaymentRemark())
                .orderByDesc(ContractPaymentPlanDO::getId));
    }

    default ContractPaymentPlanDO selectByContractId(Long contractId){
        LambdaQueryWrapperX<ContractPaymentPlanDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(ContractPaymentPlanDO::getContractId, contractId);
        return selectOne(queryWrapper);
    }

    default List<ContractPaymentPlanDO> selectByContractIds(List<Long> contractIds){
        LambdaQueryWrapperX<ContractPaymentPlanDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.in(ContractPaymentPlanDO::getContractNo, contractIds);
        return selectList(queryWrapper);
    }
}